﻿using XEvolve.Presentation.Input;

namespace XEvolve.Presentation.Internal
{
    public class NavigationHandler : ICommandHandler
    {
        private readonly INavigator navigator;

        public NavigationHandler(INavigator navigator)
        {
            this.navigator = navigator;
        }

        public void Execute(object sender, object parameter)
        {
            if (parameter == null || !(parameter is Navigation.NavigationParameter)) return;
            var navigationParameter = (Navigation.NavigationParameter)parameter;        
            navigator.Open(navigationParameter.ViewId, navigationParameter.ViewInstanceId, navigationParameter.Parameter);
        }

        public bool CanExecute(object sender, object parameter)
        {
            return true;
        }
    }
}
